#include<bits/stdc++.h>
using namespace std;
long long n,l,r,sum=0;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%lld%lld%lld",&n,&l,&r);
	for(long long i=l;i<=r;i++){
		if(i%n>sum){
			sum=i%n;
		}
	}
	cout<<sum;
	return 0;
 } 
